home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_emacs.idb / usr / freeware / share / emacs / 19.34 / lisp / case-table.el.z / case-table.el
Encoding:
Text File  |  1998-10-28  |  4.2 KB  |  122 lines

  1. ;;; case-table.el --- code to extend the character set and support case tables.
  2.  
  3. ;; Copyright (C) 1988, 1994 Free Software Foundation, Inc.
  4.  
  5. ;; Author: Howard Gayle
  6. ;; Maintainer: FSF
  7. ;; Keywords: i18n
  8.  
  9. ;; This file is part of GNU Emacs.
  10.  
  11. ;; GNU Emacs is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 2, or (at your option)
  14. ;; any later version.
  15.  
  16. ;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ;; GNU General Public License for more details.
  20.  
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs; see the file COPYING.  If not, write to the
  23. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24. ;; Boston, MA 02111-1307, USA.
  25.  
  26. ;;; Commentary:
  27.  
  28. ;; Written by:
  29. ;; TN/ETX/TX/UMG Howard Gayle        UUCP : seismo!enea!erix!howard
  30. ;; Telefonaktiebolaget L M Ericsson  Phone: +46 8 719 55 65
  31. ;; Ericsson Telecom              Telex: 14910 ERIC S
  32. ;; S-126 25 Stockholm                FAX  : +46 8 719 64 82
  33. ;; Sweden
  34.  
  35. ;;; Code:
  36.  
  37. ;;;###autoload
  38. (defun describe-buffer-case-table ()
  39.   "Describe the case table of the current buffer."
  40.   (interactive)
  41.   (let ((description (make-char-table 'case-table)))
  42.     (map-char-table
  43.      (function (lambda (key value)
  44.          (set-char-table-range
  45.           description key
  46.           (cond ((null key)
  47.              "case-invariant")
  48.             ((/= key (downcase key))
  49.              (concat "uppercase, matches "
  50.                  (char-to-string (downcase key))))
  51.             ((/= key (upcase key))
  52.              (concat "lowercase, matches "
  53.                  (char-to-string (upcase key))))
  54.             (t "case-invariant")))))
  55.      (current-case-table))
  56.     (save-excursion
  57.      (with-output-to-temp-buffer "*Help*"
  58.        (set-buffer standard-output)
  59.        (describe-vector description)
  60.        (help-mode)))))
  61.  
  62. ;;;###autoload
  63. (defun copy-case-table (case-table)
  64.   (let ((copy (copy-sequence case-table)))
  65.     ;; Clear out the extra slots so that they will be
  66.     ;; recomputed from the main (downcase) table.
  67.     (set-char-table-extra-slot copy 0 nil)
  68.     (set-char-table-extra-slot copy 1 nil)
  69.     (set-char-table-extra-slot copy 2 nil)
  70.     copy))
  71.     
  72. ;;;###autoload
  73. (defun set-case-syntax-delims (l r table)
  74.   "Make characters L and R a matching pair of non-case-converting delimiters.
  75. This sets the entries for L and R in TABLE, which is a string
  76. that will be used as the downcase part of a case table.
  77. It also modifies `standard-syntax-table' to
  78. indicate left and right delimiters."
  79.   (aset table l l)
  80.   (aset table r r)
  81.   ;; Clear out the extra slots so that they will be
  82.   ;; recomputed from the main (downcase) table.
  83.   (set-char-table-extra-slot table 0 nil)
  84.   (set-char-table-extra-slot table 1 nil)
  85.   (set-char-table-extra-slot table 2 nil)
  86.   (modify-syntax-entry l (concat "(" (char-to-string r) "  ")
  87.                (standard-syntax-table))
  88.   (modify-syntax-entry r (concat ")" (char-to-string l) "  ")
  89.                (standard-syntax-table)))
  90.  
  91. ;;;###autoload
  92. (defun set-case-syntax-pair (uc lc table)
  93.   "Make characters UC and LC a pair of inter-case-converting letters.
  94. This sets the entries for characters UC and LC in TABLE, which is a string
  95. that will be used as the downcase part of a case table.
  96. It also modifies `standard-syntax-table' to give them the syntax of
  97. word constituents."
  98.   (aset table uc lc)
  99.   (aset table lc lc)
  100.   (set-char-table-extra-slot table 0 nil)
  101.   (set-char-table-extra-slot table 1 nil)
  102.   (set-char-table-extra-slot table 2 nil)
  103.   (modify-syntax-entry lc "w   " (standard-syntax-table))
  104.   (modify-syntax-entry uc "w   " (standard-syntax-table)))
  105.  
  106. ;;;###autoload
  107. (defun set-case-syntax (c syntax table)
  108.   "Make characters C case-invariant with syntax SYNTAX.
  109. This sets the entries for character C in TABLE, which is a string
  110. that will be used as the downcase part of a case table.
  111. It also modifies `standard-syntax-table'.
  112. SYNTAX should be \" \", \"w\", \".\" or \"_\"."
  113.   (aset table c c)
  114.   (set-char-table-extra-slot table 0 nil)
  115.   (set-char-table-extra-slot table 1 nil)
  116.   (set-char-table-extra-slot table 2 nil)
  117.   (modify-syntax-entry c syntax (standard-syntax-table)))
  118.  
  119. (provide 'case-table)
  120.  
  121. ;;; case-table.el ends here
  122.